package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.pojo.Member;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface MemberDao {
    /**
     * 保存会员信息
     *
     * @param member
     */
    public void add(Member member);

    /**
     * 根据手机号查询会员信息
     *
     * @param telephone
     * @return
     */
    public Member findByTelephone(String telephone);

    /**
     * 根据id查询会员详情
     * @param id
     * @return
     */
    public Member findById(Integer id);

    /**
     * 查询给定月份的会员数量
     * @param month
     * @return
     */
    Integer findMemberCountBeforeDate(String month);

    /**
     * 查询今日新增会员数
     * @param today
     * @return
     */
    Integer findMemberCountByDate(String today);


    /**
     * 查询总会员数
     * @return
     */
    Integer findMemberTotalCount();


    /**
     * 查询一个时间之后至今的新增会员数
     * @param time
     * @return
     */
    Integer findMemberCountAfterDate(String time);



    /**
     * 会员年龄分布数量
     * @return
     */
    @Select("select count(ages) as count from (select age,case when age between 0 and 6 then '婴幼儿' when age between 7 and 12 then '少儿' when age between 13 and 17 then '青少年' when age between 18 and 45 then '青年' when age between 46 and 69 then '中年' when age > 69 then '老年' end as 'ages' from t_member order by age) as membercount group by ages")
    List<Integer> findMemberCountByAge();

    Page<Member> selectByCondition(String queryString);

    int selectMemberReferencedCount(Integer id);

    void deleteById(Integer id);

    void update(Member member);

    List<Member> findAll();


    public void edit(Member member);

}
